/* the example on page 94 */

#include <gtk/gtk.h>
/* 准备材料，自定义函数  */
	/*  comments注释  */

/* 程序主体 */
int main( int argc, char *argv[] )
{
	GtkWidget *window;
	/* 声明变量window为构件gtkwidget */
	GtkWidget *view;
	GtkTextBuffer *buffer;
	GtkTextIter iter;
	/*  迭代器类型，注意iter前面是没有星号*的 */
	
	gtk_init (&argc, &argv);
	/* 初始化gtk */

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	/*  创建顶级窗口 */
	gtk_window_set_title (GTK_WINDOW (window), "昨日诗yesterday_verse");
	/*  为窗口顶部加上标题为昨日诗yesterday_verse  */
	g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
	/*  为窗口加上动作，当收到destroy信号，就启动gtk_main_quit事件，gtk_main_quit就是鼠标单击窗口右上角的关闭按钮就终止程序  */
	gtk_container_set_border_width (GTK_CONTAINER (window), 10);
	/*  简单的理解是将窗口变成容器，可以装入其它构件，构件边缘与窗口边缘的距离为10像数  */
	view = gtk_text_view_new ();
	/*  创建文本显示构件 */
	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	/*  创建缓冲区域，用来存储数据，并与构件view联系起来 */
	gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
	/*  初始化缓冲区域 */
	gtk_text_buffer_insert (buffer, &iter, "\t昨日诗\n", -1);
	/*  创建一个新行并写入数据，\t表示TAB键4个空格，\n表示回车换行，-1表示数据的结尾 */
	gtk_text_buffer_insert (buffer, &iter, "昨日兮昨日，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "昨日何其好！\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "昨日过去了，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "今日徒懊恼。\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "世人但知悔昨日，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "不觉今日又过了。\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "水去日日流，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "花落日日少，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "成事立业在今日，\n", -1);
	gtk_text_buffer_insert (buffer, &iter, "莫待明朝悔今朝。\n", -1);
	gtk_container_add (GTK_CONTAINER (window), view);
	/*  将构件view装主窗口容器 */
	gtk_widget_show_all (window);
	/*  显示构件窗口包括所有构件  */
	gtk_main ();
	/*  进入主循环，等待信号（鼠标键盘）输入  */
	return 0;
}
/* gcc pageXX.c -o pageXX `pkg-config --cflags --libs gtk+-3.0` */
